#include "adc_app.h"

uint32_t adc_buffer[30];
float adc_dat;

void adc_proc(void)
{

	for(uint8_t i = 0;i<30;i++)
	{
		adc_dat += adc_buffer[i];
	}
	
	adc_dat = (adc_dat / 30) * 3.3 / 4096;
	if(!duty_clock)
	{
	adc_set_duty(adc_dat);
	}
}

uint8_t duty_dat;
void adc_set_duty(float adc_buffer)
{
	if(adc_buffer < 1)
	{
		set_pwm_duty(10);
	}
	else if(adc_buffer >= 1 && adc_buffer <= 3)
	{
		set_pwm_duty(37.5 * adc_buffer - 27.5);
	}
	else if(adc_buffer > 3)
	{
		set_pwm_duty(85);
	}
	
}
	

